const { app } = require('electron')

import { createMainWindow } from '../renderer/src/libs/windowManager'
import { initializeApp } from '../renderer/src/libs/appInit'
import { createTray } from '../renderer/src/libs/trayManager'
import { ipcHandles } from '../renderer/src/libs/ipcHandles'

let mainWindow = null

function getOrCreateMainWindow() {
  if (!mainWindow) {
    mainWindow = createMainWindow()
    createTray(mainWindow)
    ipcHandles(mainWindow)
  }
  return mainWindow
}

initializeApp(getOrCreateMainWindow)

app.whenReady().then(() => {
  mainWindow = getOrCreateMainWindow()
})
